/*
 * @Author: 刘鑫
 * @Date: 2020-11-18 14:50:26
 * @LastEditors: 刘鑫
 * @LastEditTime: 2020-11-23 10:35:00
 * @Description:
 */
import { RequestConfig } from 'umi';
import { getToken } from '@/utils/index';
import { RequestOptionsInit } from 'umi-request';
export const request: RequestConfig = {
  timeout: 3000,
  prefix: 'http://easymarket.jasonandjay.com',
  errorConfig: {},
  middlewares: [],
  requestInterceptors: [
    (url: string, options: RequestOptionsInit) => {
      let token = getToken();
      let headers = options.headers;
      if (token) {
        headers = { ...options.headers, 'x-nideshop-token': token };
      }
      return {
        url,
        options: { ...options, headers },
      };
    },
  ],
  responseInterceptors: [],
};
